
<html xmlns:util="jelly:util" xmlns:util="jelly:util">

  <HEAD>
  
    <link rel="stylesheet" href="style/default.css" type="text/css">
  
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <title>JAXB RI 2.1.9 fcs -- Binding Compiler (xjc)
    </title>
    <link rel="alternate" href="https://jaxb.dev.java.net/servlets/ProjectNewsRSS" type="application/rss+xml">
  </HEAD>


  <BODY>
    <h1>
      <banner>
    Java
        <sup>
          <font size="-2">TM</font>
        </sup> Architecture for XML Binding
  
      </banner>
      <br>
      Binding Compiler (xjc) 
    
    </h1>
    <center>
      <b>Implementation Version:</b> 2.1.9 fcs
      <br>
    </center>
    <table class="navbar" cellspacing="0">
      <tr>
        <td class="inactive">
          <a href="index.html">JAXB 2.0</a>
        </td>
        <td class="active">
          <a>Tools</a>
        </td>
        <td class="inactive">
          <a href="jaxb-1_0.html">JAXB 1.0.x</a>
        </td>
        <td class="inactive">
          <a href="vendor.html">JAXB RI Extensions</a>
        </td>
        <td class="inactive">
          <a href="community.html">JAXB Community</a>
        </td>
      </tr>
    </table>
    <div class="subnavbar">
      <ul>
        <li class="first">
          <a href="xjc.html">
            <span class="active">XJC </span>
          </a>
        </li>
        <li>
          <a href="xjcTask.html">
            <span>XJC Ant Task </span>
          </a>
        </li>
        <li>
          <a href="schemagen.html">
            <span>SchemaGen </span>
          </a>
        </li>
        <li>
          <a href="schemagenTask.html">
            <span>SchemaGen Ant Task </span>
          </a>
        </li>
        <li>
          <a href="3rdparty.html">
            <span>3rd Party Tools </span>
          </a>
        </li>
      </ul>
    </div>
  
    <header></header>



    <p>
  
    <h2>Launching xjc</h2>
  
    <p>The binding compiler can be launched using the appropriate 
     
      <code>xjc</code> shell script in the 
      <code>bin</code> directory 
     for your platform.  We also provide an Ant task to run the binding
     complier - see the instructions for 
      <a href="xjcTask.html">
     using xjc with Ant</a>.
    

  
    <blockquote>
    
      <h4>For Solaris/Linux</h4>
      
      <blockquote>
          
        <ol>
            
          <li>
            <tt>% /path/to/jaxb/bin/xjc.sh -help</tt>
          </li>
          
        </ol>
        
      </blockquote>
      
    </blockquote>

  
    <blockquote>
    
      <h4>For WindowsNT/2000/XP</h4>
      
      <blockquote>
        
        <ol>
          
          <li>
            <tt>&gt; c:\path\to\jaxb\bin\xjc.bat -help</tt>
          </li>
          
        </ol>
        
      </blockquote>
      
    </blockquote>

  

  
    <blockquote>
    
      <h4>Output</h4>
    
      <blockquote>
      
      
      
        <pre>Usage: xjc [-options ...] &lt;schema file/URL/dir/jar&gt; ... [-b &lt;bindinfo&gt;] ...
If dir is specified, all schema files in it will be compiled.
If jar is specified, /META-INF/sun-jaxb.episode binding file will be compiled.
Options:
  -nv                :  do not perform strict validation of the input schema(s)
  -extension         :  allow vendor extensions - do not strictly follow the
                        Compatibility Rules and App E.2 from the JAXB Spec
  -b &lt;file/dir&gt;      :  specify external bindings files (each &lt;file&gt; must have its own -b)
                        If a directory is given, **/*.xjb is searched
  -d &lt;dir&gt;           :  generated files will go into this directory
  -p &lt;pkg&gt;           :  specifies the target package
  -httpproxy &lt;proxy&gt; :  set HTTP/HTTPS proxy. Format is [user[:password]@]proxyHost:proxyPort
  -httpproxyfile &lt;f&gt; :  Works like -httpproxy but takes the argument in a file to protect password 
  -classpath &lt;arg&gt;   :  specify where to find user class files
  -catalog &lt;file&gt;    :  specify catalog files to resolve external entity references
                        support TR9401, XCatalog, and OASIS XML Catalog format.
  -readOnly          :  generated files will be in read-only mode
  -npa               :  suppress generation of package level annotations (**/package-info.java)
  -no-header         :  suppress generation of a file header with timestamp
  -target 2.0        :  behave like XJC 2.0 and generate code that doesn't use any 2.1 features.
  -xmlschema         :  treat input as W3C XML Schema (default)
  -relaxng           :  treat input as RELAX NG (experimental,unsupported)
  -relaxng-compact   :  treat input as RELAX NG compact syntax (experimental,unsupported)
  -dtd               :  treat input as XML DTD (experimental,unsupported)
  -wsdl              :  treat input as WSDL and compile schemas inside it (experimental,unsupported)
  -verbose           :  be extra verbose
  -quiet             :  suppress compiler output
  -help              :  display this help message
  -version           :  display version information
</pre>
    
      </blockquote>
  
    </blockquote>
    
    
    <blockquote>
      
      <h4>Execute the 
        <code>jaxb-xjc.jar</code> JAR File
      </h4>
      
      <blockquote>
        
        <p>If all else fails, you should be able to execute the 
           
          <code>jaxb-xjc.jar</code> file:
        
        
        <blockquote>
          
          <dl>
            
            <dt>For Solaris/Linux:</dt> 
            
            <dd>
              <tt>% java -jar $JAXB_HOME/lib/jaxb-xjc.jar -help</tt>
            </dd>
            
            <dt>For Windows:</dt>
            
            <dd>
              <tt>&gt; java -jar %JAXB_HOME%\lib\jaxb-xjc.jar -help</tt>
            </dd>
          
          </dl>
        
        </blockquote>
        
        <p>
          This is equivalent of running "xjc.sh" or "xjc.bat", and it allows you to set the JVM parameters.
        
      
      </blockquote>
  
    </blockquote>
  
  
    <a name="switches"></a>
  
    <h2>Summary of Command Line Options</h2>
  
    <dl class="cli-options">
    
      <dt>
        <b>-nv</b>
      </dt>
    
      <dd>By default, the XJC binding compiler performs strict validation of the source schema before 
        processing it.  Use this option to disable strict schema validation.  This
        does not mean that the binding compiler will not perform any validation, it
        simply means that it will perform less-strict validation.</dd>
    
      <dt>
        <b>-extension</b>
      </dt>
    
      <dd>By default, the XJC binding compiler strictly enforces the rules outlined in the Compatibility
        chapter of the JAXB Specification.  Appendix E.2 defines a set of W3C XML
        Schema features that are not completely supported by JAXB v1.0.  In some
        cases, you may be allowed to use them in the "-extension" mode
        enabled by this switch.  In the default (strict) mode, you are also limited
        to using only the binding customizations defined in the specification.
        By using the "-extension" switch, you will be allowed to use the
        
        <a href="vendor.html">JAXB Vendor Extensions</a>.
      </dd>
    
      <dt>
        <b>-b &lt;file&gt;</b>
      </dt>
    
      <dd>Specify one or more external binding files to process. (Each binding file must
        have it's own 
        <tt>"-b"</tt> switch.)  The syntax of the external
        binding files is extremely flexible.  You may have a single binding file
        that contains customizations for multiple schemas or you can break the
        customizations into multiple bindings files:
        <p>
        
        <blockquote>
          
          <tt>xjc schema1.xsd schema2.xsd schema3.xsd -b bindings123.xjb
            <br>
              xjc schema1.xsd schema2.xsd schema3.xsd -b bindings1.xjb -b bindings2.xjb -b bindings3.xjb
          </tt>
        
        </blockquote>
        In addition, the ordering of the schema files and binding files on the
        command line does not matter.
        
      </dd>
    
      <dt>
        <b>-d &lt;dir&gt;</b>
      </dt>
    
      <dd>By default, the XJC binding compiler will generate the Java content classes in the current
        directory.  Use this option to specify an alternate output directory.
        The output directory must already exist, the XJC binding compiler will not create it for you.
        </dd>
    
      <dt>
        <b>-p &lt;pkg&gt;</b>
      </dt>
    
      <dd>Specifying a target package via this command-line option overrides
        any binding customization for package name and the default package
        name algorithm defined in the specification.</dd>
    
      <dt>
        <b>-httpproxy &lt;proxy&gt;</b>
      </dt>
    
      <dd>Specify the HTTP/HTTPS proxy. The format is [user[:password]@]proxyHost[:proxyPort].  The old 
        <tt>-host</tt>
        and 
        <tt>-port</tt> are still supported by the RI for backwards compatibility, but they have been deprecated.
      </dd>
    
      <dt>
        <b>-httpproxyfile &lt;f&gt;</b>
      </dt>
    
      <dd>Same as the 
        <tt>-httpproxy &lt;proxy&gt;</tt> option, but it takes the &lt;proxy&gt; parameter in a file, so that you can protect the password (passing a password in the argument list is not safe.)
      </dd>
    
      <dt>
        <b>-classpath &lt;arg&gt;</b>
      </dt>
    
      <dd>Specify where to find client application class files 
        used by the 
        <tt>&lt;jxb:javaType&gt;</tt> and 
        <tt>&lt;xjc:superClass&gt;</tt>
        customizations.
      </dd>
    
      <dt>
        <b>-catalog &lt;file&gt;</b>
      </dt>
    
      <dd>Specify catalog files to resolve external entity references.  Supports TR9401, 
        XCatalog, and OASIS XML Catalog format.  Please read the 
        <a href="catalog.html">
        XML Entity and URI Resolvers</a> document or the 
        <tt>catalog-resolver</tt> sample application.
      </dd>
      
      <dt>
        <b>-readOnly</b>
      </dt>
      
      <dd>By default, the XJC binding compiler does not write-protect the Java source files it generates.
          Use this option to force the XJC binding compiler to mark the generated Java sources read-only.</dd>
    
      <dt>
        <b>-npa</b>
      </dt>
    
      <dd>Supress the generation of package level annotations into **/package-info.java.  Using this
        switch causes the generated code to internalize those annotations into the other generated
        classes.</dd>
    
      <dt>
        <b>-no-header</b>
      </dt>
    
      <dd>Supress the generation of a file header comment that includes some note and timestamp. Using
        this makes the generated code more 
        <tt>diff</tt>-friendly.
      </dd>
    
      <dt>
        <b>-target 2.0</b>
      </dt>
    
      <dd>Avoid generating code that relies on any JAXB 2.1 features. This will allow the generated code to run with JAXB 2.0 runtime (such as JavaSE 6.)</dd>
    
      <dt>
        <b>-xmlschema</b>
      </dt>
    
      <dd>treat input schemas as W3C XML Schema (default).  If you do not specify this
        switch, your input schemas will be treated as W3C XML Schema.</dd>
    
      <dt>
        <b>-relaxng</b>
      </dt>
    
      <dd>Treat input schemas as RELAX NG (experimental, unsupported).  Support for
        RELAX NG schemas is provided as a 
        <a href="vendor.html">JAXB Vendor Extension</a>.
        
      </dd>
    
      <dt>
        <b>-relaxng-compact</b>
      </dt>
    
      <dd>Treat input schemas as RELAX NG compact syntax(experimental, unsupported).  Support for
        RELAX NG schemas is provided as a 
        <a href="vendor.html">JAXB Vendor Extension</a>.
        
      </dd>
    
      <dt>
        <b>-dtd</b>
      </dt>
    
      <dd>Treat input schemas as XML DTD (experimental, unsupported).  Support for 
        RELAX NG schemas is provided as a 
        <a href="vendor.html">JAXB Vendor Extension</a>.
      </dd>
    
      <dt>
        <b>-wsdl</b>
      </dt>
    
      <dd>Treat input as WSDL and compile schemas inside it (experimental,unsupported).</dd>
    
      <dt>
        <b>-quiet</b>
      </dt>
    
      <dd>Suppress compiler output, such as progress information and warnings..
        </dd>
    
      <dt>
        <b>-verbose</b>
      </dt>
    
      <dd>Be extra verbose, such as printing informational messages or displaying stack traces upon some errors..
        </dd>
    
      <dt>
        <b>-help</b>
      </dt>
    
      <dd>Display a brief summary of the compiler switches.</dd>
    
      <dt>
        <b>-version</b>
      </dt>
    
      <dd>Display the compiler version information.</dd>
    
      <dt>
        <b>&lt;schema file/URL/dir&gt;</b>
      </dt>
    
      <dd>Specify one or more schema files to compile.  If you specify a directory, then xjc
        will scan it for all schema files and compile them.</dd>
    
      <dt>
        <b>-Xlocator</b>
      </dt>
    
      <dd>This feature causes the generated code to expose SAX Locator information
        about the source XML in the Java bean instances after unmarshalling.</dd>
    
      <dt>
        <b>-Xsync-methods</b>
      </dt>
    
      <dd>This feature causes all of the generated method signatures to include the
        synchronized keyword.</dd>
    
      <dt>
        <b>-mark-generated</b>
      </dt>
    
      <dd>This feature causes all of the generated code to have 
        <a href="http://java.sun.com/javaee/5/docs/api/index.html?javax/annotation/Generated.html">
          <tt>@Generated</tt>
        </a> annotation.
      </dd>
    
      <dt>
        <b>-episode &lt;FILE&gt;</b>
      </dt>
    
      <dd>Generate an episode file from this compilation, so that other schemas that rely on this schema can be compiled later and rely on classes that are generated from this compilation. The generated episode file is really just a JAXB customization file (but with vendor extensions.)</dd>
    
    </dl>

  

    
    <h2>Summary of Deprecated and Removed Command Line Options</h2>
    
    <dl class="cli-options">
      
      <dt>
        <b>-host &amp; -port</b>
      </dt>
      
      <dd>These options have been deprecated and replaced with the 
        <b>-httpproxy</b> option.  For
          backwards compatibility, we will continue to support these options, but they will no
          longer be documented and may be removed from future releases.
      </dd>
      
      <dt>
        <b>-use-runtime</b>
      </dt>
      
      <dd>Since the JAXB 2.0 specification has defined a portable runtime, it is no longer
          necessary for the JAXB RI to generate **/impl/runtime packages.  Therefore, this
          switch is obsolete and has been removed.</dd>
      
      <dt>
        <b>-source</b>
      </dt>
      
      <dd>The -source compatibility switch was introduced in the first JAXB 2.0 Early Access
          release for convenience reasons. You shall not rely on this switch, because it might get
          removed from any future release of JAXB 2.0. If you need to generate 1.0.x code, please use
          an installation of the 1.0.x codebase.</dd>
    
    </dl>

    
    <a name="restrictions"></a>
    
    <h2>Compiler Restrictions</h2>
    
    <p>In general, it is safest to compile all related schemas as a single unit with
       the same binding compiler switches.
       
    
    <p>Please keep the following list of restrictions in mind when running xjc.  Most 
       of these issues only apply when compiling multiple schemas with multiple 
       invocations of xjc.
      
    <ul>
        
      <li>To compile multiple schemas at the same time, keep the following 
            precedence rules for the target Java package name in mind:
       
            
        <ol>
              
          <li>The "
            <tt>-p</tt>" command line option takes the highest precedence.
          </li>
              
          <li>
            <tt>&lt;jaxb:package&gt;</tt> customization
          </li>
              
          <li>If 
            <tt>targetNamespace</tt> is declared, apply 
            <tt>targetNamespace</tt> 
                  -&gt; Java package name algorithm defined in the specification.
          </li>
              
          <li>If no 
            <tt>targetNamespace</tt> is declared, use a hardcoded package named 
                  "generated".
          </li>
            
        </ol>
        
      </li>
    
        
      <li>It is not legal to have more than one &lt;
        <tt>jaxb:schemaBindings</tt>&gt;
            per namespace, so it is impossible to have two schemas in the same target 
            namespace compiled into different Java packages.
      </li>
       
        
      <li>All schemas being compiled into the same Java package must be submitted to the 
            XJC binding compiler at the same time - they cannot be compiled independently 
            and work as expected.</li>
        
      <li>Element substitution groups spread across
            multiple schema files must be compiled at the same time.</li>
      
    </ul>
    
    
    <a name="xjcresources"></a>
    
    <h2>Generated Resource Files</h2>
    
    <p>
      XJC produces a set of packages containing Java source files and also 
      <tt>jaxb.properties</tt> files, depending on the binding options you used for compilation. When generated, 
      <tt>jaxb.properties</tt> files must be kept with the compiled source code and made available on the runtime classpath of your client applications:

    
  
    
    <hr>
  
    <div class="footer">
    $Revision: 1.2 $
      <br>
    $Date: 2008/06/20 08:36:11 $
  
    </div>
  


  </BODY>
</html>